//添加一级菜单
function addOneMenu(){

	$("#onemenutable").show(1000);
	$("#twomenutable").hide(50);
};

//添加二级菜单
function addTwoMenu(){
//	window.location.href="Privilege_addPage";
	$("#onemenutable").hide(50);
	$("#twomenutable").show(1000);
}

//保存一级菜单
function saveaddOneMenu(formid,requestUrl){
	var name=$("#onename").val();
	var url=$("#oneurl").val();
	if(name.length==0){
		alert("名称不能为空");
		return ;
	}
	if(url.length==0){
		alert("URL地址不能为空!");
		return ;
	}
	
	var result = SaveForm(formid, requestUrl);
	if(result == "success"){
		alert("保存成功");
//		window.location.href="Login_loginPage";
	}else{
		alert("保存失败！");
	}
}


//保存二级菜单
function saveaddtwoMenu(formid,requestUrl){
	var parentid=$("#parentid").val();
	var name=$("#twoname").val();
	var url=$("#twourl").val();
	if(parentid==0){
		alert("请选择一级菜单");
		return ;
	}
	if(name.length==0){
		alert("名称不能为空");
		return ;
	}
	if(url.length==0){
		alert("URL地址不能为空!");
		return ;
	}
	var result = SaveForm(formid, requestUrl);
	if(result == "success"){
		alert("保存成功");
//		window.location.href="Login_loginPage";
	}else{
		alert("保存失败！");
	}
}

//删除数据
function deletePrivilege(va){
	$.ajax({
		type:"POST",
		url:"Privilege_delete",
		data:{"privilege.id":va},
		async: false,
			error: function(request) {
			alert("请求失败"+request.responseText);
			},
		success:function(data){
			result = String($.trim(data));
			if(result=="success"){
				alert("删除成功！");
				window.location.href="Privilege_list";
			}else{
				alert("删除失败！")
			}
		}
	});
}

//返回
function back(){
	window.location.href="Privilege_list";
}

//更新二级菜单
function ToupdateTwoMenu(formid,requestUrl){
	var result = SaveForm(formid, requestUrl);
	if(result == "success"){
		alert("保存成功");
	}else{
		alert("保存失败！");
	}
}
//更新一级菜单
function ToupdateOneMenu(formid,requestUrl){
	var result = SaveForm(formid, requestUrl);
	if(result == "success"){
		alert("保存成功");
	}else{
		alert("保存失败！");
	}
}
